(use-package ivy
  ;; :commands (ivy-read)
  :hook (after-init . ivy-mode)
  :diminish (ivy-mode)
  :bind
  (("C-c C-r" . ivy-resume)
   ([remap list-buffers] . ivy-switch-buffer)
   ([remap switch-to-buffer] . ivy-switch-buffer)
   ([remap switch-to-buffer-other-window] . ivy-switch-buffer-other-window)
   ;; :package ivy
   :map ivy-minibuffer-map
   ("C-g" . abort-recursive-edit)
   )
  ;; :init
  ;; (defvar projectile-completion-system)
  ;; (defvar magit-completing-read-function)
  ;; (defvar projector-completion-system)
  ;; (setq projectile-completion-system 'ivy
  ;;       magit-completing-read-function 'ivy-completing-read)
  ;; :commands (ivy-completing-read
  ;;	     ivy-completion-in-region
  ;;	     swiper)
  :custom
  (ivy-use-selectable-prompt t)
  (enable-recursive-minibuffers t)
  ;; enable this if you want `swiper' to use it
  (search-default-mode #'char-fold-to-regexp)
  ;; (ivy-mode t)
  (ivy-count-format "(%d/%d) ")
  (ivy-re-builders-alist
   '((t . ivy--regex-plus) ;
     (webjump . ivy--regex-fuzzy)
     (swiper . ivy--regex-plus)))
  (ivy-initial-inputs-alist '(;; (t . "^")
			      (t . nil)
			      ;; (webjump . nil)
			      ;; (Man-completion-table . nil)
			      )))

(use-package counsel
  :diminish counsel-mode
  :hook (after-init . counsel-mode)
  ;; :commands (counsel-mode counsel-descbinds
  ;;			  counsel-grep-or-swiper)
  :bind (("C-c n" . counsel-fzf)
	 ([remap execute-extended-command] . counsel-M-x)
	 ([remap find-library] . counsel-find-library)
	 ([remap find-file] . counsel-find-file)
	 ([remap describe-bindings]  .
	  counsel-descbinds)
	 ([remap describe-face]  .
	  counsel-describe-faces)
	 ([remap list-faces-display] . counsel-faces)
	 ([remap imenu] . counsel-imenu)
	 ([remap load-library] . counsel-load-library)
	 ([remap load-theme] . counsel-load-theme)
	 ([remap yank-pop] . counsel-yank-pop)
	 ([remap info-lookup-symbol] . counsel-info-lookup-symbol)
	 ([remap pop-to-mark-command] . counsel-mark-ring)
	 ([remap bookmark-jump] . counsel-bookmark)
	 ;; ("C-c j" . counsel-git-grep)
	 ;; ("C-x l" . counsel-locate)
	 ([remap insert-char] . counsel-unicode-char)
	 ([remap find-file] . counsel-find-file)
	 ([remap describe-function] . counsel-describe-function)
	 ([remap describe-variable] . counsel-describe-variable)
	 ([remap find-library] . counsel-find-library)
	 ([remap eshell-previous-matching-input-from-input] . counsel-esh-history)
	 ([remap yank-pop] . counsel-yank-pop)
	 )
  )
